package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.dao.FindAllDepDao;
import com.jx.daoimpl.FindAllDepDaoImpl;
import com.jx.model.Dep;
import com.jx.model.Func;
import com.jx.service.FindAllDepService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class FindCurrDepController extends HttpServlet{
	FindAllDepDao fad=new FindAllDepDaoImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		
		List<Dep> deps=fad.findAllDeoDao(0, fad.findTotalDep());
		
		JSONArray depcsarr=new JSONArray();
		JSONObject jdep=new JSONObject();
		for (Dep dep : deps) {
			jdep.put("dep", dep);
			depcsarr.add(jdep);
		}
		
		PrintWriter pw=resp.getWriter();
		pw.write(String.valueOf(depcsarr));
	}
}
